#include <Windows.h>
#include <tchar.h>
#include "resource.h"

int CALLBACK DlgProc(HWND hDlg, UINT nMsg, WPARAM wParam, LPARAM lParam)
{
	switch (nMsg)
	{
		case WM_INITDIALOG:
		{
			SetWindowText(hDlg, _T("ResExe"));

			UINT nWidth		= GetSystemMetrics(SM_CXSCREEN);
			UINT nHeight	= GetSystemMetrics(SM_CYSCREEN);
			RECT rtClient;
			GetClientRect(hDlg, &rtClient);
			SetWindowPos(hDlg, NULL, (nWidth - (rtClient.right - rtClient.left)) / 2, (nHeight - (rtClient.bottom - rtClient.top)) / 2, 0, 0, SWP_NOSIZE);
			
			break;
		}
		case WM_COMMAND:
		{
			break;
		}
		case WM_CLOSE:
		{
			PostQuitMessage(0);
			break;
		}
	}

	return 0;
}

BOOL WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPreInstance, LPTSTR szCmdLine, int nShowCmd)
{
	DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG), NULL, DlgProc);

	return TRUE;
}
/*
DWORD dwSize = 0;
DWORD dwLen = GetFileVersionInfoSize(szExePath, &dwSize);
BYTE* lpVer = new BYTE[dwLen];
GetFileVersionInfo(szExePath, NULL, dwLen, lpVer);
BYTE* szBuff;
UINT nBufLen = 0;
VerQueryValue(lpVer, _T("\\VarFileInfo\\Translation"), (LPVOID*)&szBuff, (PUINT)&nBufLen);

struct LANGANDCODEPAGE {
	WORD wLanguage;
	WORD wCodePage;
} *lpTranslate;
for(int ii = 0; ii < (nBufLen / sizeof(LANGANDCODEPAGE)); ii++ )
{
	TCHAR szSubBlock[MAX_PATH];
	_stprintf(szSubBlock, MAX_PATH,	TEXT("\\StringFileInfo\\%04x%04x\\FileDescription"),
		szBuff[ii].wLanguage,
		szBuff[ii].wCodePage);
	if (FAILED(hr))
	{
		// TODO: write error handler.
	}

	// Retrieve file description for language and code page "i". 
	VerQueryValue(lpVer, szSubBlock, &lpBuffer, &dwBytes);
}
delete[] lpVer;*/